<?php

namespace App\Http\Controllers\Merchant;

use App\Http\Response;
use App\MchSponsorTem;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class SponsorMoneyController extends Controller
{
    use Response;
    protected $mch_id;

    /**
     * SponsorMoneyController constructor.
     * @param $mch_id
     */
    public function __construct()
    {
        $this->mch_id = auth('merchant')->id();
    }

    public function index(Request $request)
    {
//        $template=config('sponsor_template.template');
        $data=MchSponsorTem::where('mch_id',$this->mch_id)->first();
//        $data['template']=$template;
        return $this->success(200,$data);
    }
    public function store(Request $request)
    {
        $request->merge(["mch_id"=>$this->mch_id]);
        $create=MchSponsorTem::create($request->all());
        if ($create){
            return $this->message(200,trans('topic.create success'));
        }else{
            return $this->error(505,trans('topic.create_failed'));
        }
    }
}
